package com.srzk.youthleagueback.controller;


import com.srzk.youthleagueback.pojo.Meeting;
import com.srzk.youthleagueback.results.Result;
import com.srzk.youthleagueback.service.MeetingService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/part2")
public class MeetingMinutesController {
    @Autowired
    MeetingService meetingService;

    @GetMapping("/meetingMinutesList")
    public Result<List<Object>> getMeeting(@RequestParam("user") String user, @RequestParam("year") String year, @RequestParam("type") int type) {
        return meetingService.getMeetingList(user, year, type);
    }

    @GetMapping("/meetingMinutes")
    public Result<Map<String, Object>> getMeeting(@RequestParam("user") String user, @RequestParam("year") String year, @RequestParam("type") int type, @RequestParam("id") int id) {
        return meetingService.getMeeting(user, year, type, id);
    }

    @PostMapping("/meetingMinutes")
    public Result<Map<String, Long>> addMeeting(Meeting meeting) {
        return meetingService.addMeeting(meeting);
    }

    @DeleteMapping("/meetingMinutes")
    public Result<String> deleteMeeting(@RequestParam("user") String user, @RequestParam("year") String year, @RequestParam("type") int type, @RequestParam("id") int id) {
        return meetingService.deleteMeeting(user, year, type, id);
    }

    @PostMapping("/meetingMinutesUpdate")
    public Result<String> updateMeeting(Meeting meeting) {
        return meetingService.updateMeeting(meeting);
    }
}
